package com.example.demo.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo.pojo.Events;
import com.example.demo.service.Eservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/events")
public class EventsController {

    @Autowired
    private Eservice eservice;

    @GetMapping("/page")
    public Page<Events> page(
            @RequestParam(required = false, name = "name") String name,
            @RequestParam(defaultValue = "1") Integer current,
            @RequestParam(defaultValue = "10") Integer size
    ) {
        return eservice.page(current, size, name);
    }

    @PostMapping("/save")
    public boolean save(@RequestBody Events event) {
        return eservice.saveOrUpdateBymemberId(event);
    }

    @PostMapping("/delete")
    public boolean delete(@RequestBody List<Long> ids) {
        return eservice.deleteBatchIds(ids);
    }
}